fix: map Qwen Code portal resource_url to correct Dashscope API endpoints#12092
fix: map Qwen Code portal resource_url to correct Dashscope API endpoints#12092roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…ints The Qwen Code CLI v0.14.2+ sets resource_url to portal domains like "portal.qwen.ai" instead of Dashscope API URLs. The handler was using this value directly as the API base URL, causing 400 errors. Changes: - Add QWEN_PORTAL_CONFIG mapping for known portal domains to their corresponding Dashscope API and OAuth token endpoints - portal.qwen.ai -> dashscope-intl.aliyuncs.com (international) - chat.qwen.ai -> dashscope.aliyuncs.com (China) - Derive OAuth token endpoint from resource_url instead of hardcoding chat.qwen.ai, so international users hit the correct token server - Add comprehensive tests for URL mapping behavior Closes #12061
|
Hello guys, I've tried to compile .vsix file from this branch and install it directly to the VS Code and I faced another problem with refreshing token. I tried also to reinstall qwen code plugin and execute Roo again, it didn't help. Error details from Roo console: Thanks in advance |
Related GitHub Issue
Closes: #12061
Description
This PR attempts to address Issue #12061 where the Qwen Code provider fails with "400 bad request" for users with newer Qwen Code CLI versions (v0.14.2+).
Root Cause: The Qwen Code CLI v0.14.2+ now sets
resource_urlin~/.qwen/oauth_creds.jsonto portal domains likeportal.qwen.ai(international) orchat.qwen.ai(China). The handler was using this value directly as the API base URL, resulting in requests going tohttps://portal.qwen.ai/v1instead of the correct Dashscope API endpoint. Additionally, the OAuth token refresh endpoint was hardcoded tochat.qwen.ai, which fails for international portal users.Fix:
QWEN_PORTAL_CONFIGmapping that maps known portal domains to their corresponding Dashscope API base URLs and OAuth token endpoints:portal.qwen.ai->dashscope-intl.aliyuncs.com(international) with OAuth viaportal.qwen.aichat.qwen.ai->dashscope.aliyuncs.com(China) with OAuth viachat.qwen.aigetBaseUrlmethod now checks ifresource_urlmatches a known portal domain before using it as-isgetOAuthTokenEndpointmethod to derive the correct token endpoint from the credentialsresource_urlresource_urlis already a full dashscope URL (backward compatibility), it is used directlyTest Procedure
qwen-code-portal-mapping.spec.tscovering:portal.qwen.aimaps to dashscope-intl API endpointchat.qwen.aimaps to dashscope China API endpointresource_urlfalls back to default dashscope URLresource_urlare preservedportal.qwen.aiwithhttps://prefix is handled correctlyqwen-code-native-tools.spec.tstests continue to passcd src && npx vitest run api/providers/__tests__/qwen-code-portal-mapping.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
Feedback and guidance are welcome. The portal-to-API mapping is based on the observed pattern from Qwen Code CLI v0.14.2 credentials. If additional portal domains emerge, they can be added to the
QWEN_PORTAL_CONFIGmapping.Interactively review PR in Roo Code Cloud